home *** CD-ROM | disk | FTP | other *** search
/ MacHack 2000 / MacHack 2000.toast / pc / The Hacks / MacHacksBug / Python 1.5.2c1 / Mac / IDE scripts / Hack / Remove .pyc files… < prev    next >
Encoding:
Text File  |  2000-06-23  |  556 b   |  23 lines

  1. import sys
  2. import os
  3. import macfs
  4.  
  5. def walk(top):
  6.     names = os.listdir(top)
  7.     for name in names:
  8.         path = os.path.join(top, name)
  9.         if os.path.isdir(path):
  10.             walk(path)
  11.         else:
  12.             if path[-4:] in ['.pyc', '.pyo'] and os.path.exists(path[:-1]):
  13.                 print "deleting:", path
  14.                 os.remove(path)
  15.             elif path[-4:] == '.pyc':
  16.                 print "!!! ------ .pyc file without .py file:", path
  17.             elif path[-4:] == '.pyo':
  18.                 print "!!! ------ .pyo file without .py file:", path
  19.  
  20. fss, ok = macfs.GetDirectory('Select the starting folder:')
  21. if ok:
  22.     walk(fss.as_pathname())
  23.